package com.example.demo.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.annotation.Api;
import com.example.demo.domain.entity.Company;
import com.example.demo.domain.entity.PermissionFrontUrl;
import com.example.demo.dto.ResponseDto;
import com.example.demo.param.CompanyParam;
import com.example.demo.param.PersionParam;
import com.example.demo.service.CompanyService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * 公司管理
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/exam/company")
public class CompanyController {

    @Resource
    private CompanyService companyService;


    /**
     * 创建
     */
    @Api
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public void createCompany(@RequestBody Company entity) {
        companyService.createCompany(entity);
    }



    /**
     * 创建
     */
    @Api
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public void updateCompany(@RequestBody Company entity) {
        companyService.updateCompany(entity);
    }


    /**
     * 创建
     */
    @Api
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public void deleteCompany(@RequestBody Company entity) {
        companyService.deleteCompany(entity);
    }


    /**
     * @param companyParam
     * @return
     */
    @PostMapping("/query")
    ResponseDto queryCompany(@RequestBody CompanyParam companyParam){
        Page<Company> companyPage = companyService.queryCompany(companyParam);
        return new ResponseDto<>().buildSucceedHasData(companyPage);
    }
}
